import QtQuick 2.0
import QtQml.Models 2.1
//import "../youdao/qml"

Rectangle {
    id: main
    width: 950
    height: 600
    radius: 5
    //color : "#000000"

    property bool onstart: true
    property int index: title.currentIndex
    signal close(string str)
    signal postClicked()

    MouseArea {
        id: dragRegion
        anchors.fill: parent
        property point clickPos: "0,0"
        onPressed: {
            clickPos  = Qt.point(mouse.x,mouse.y)
        }
        onPositionChanged: {
        //鼠标偏移量
        var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
        //如果mainwindow继承自QWidget,用setPos
        mainwindow.setX(mainwindow.x+delta.x)
            mainwindow.setY(mainwindow.y+delta.y)
        }
    }

    Title {
        id:title
        anchors.top: parent.top
        width: parent.width
        height: 115
        radius: 5
        onClose:mainwindow.close()
        //onClick
    }

    HeartRate {
        id: heartrate
        anchors.top: title.bottom
        anchors.bottom: parent.bottom
        width: parent.width
        radius: 5
        visible: index == 0 ? true : false
        onPostClicked: main.postClicked()
    }

    HListView{
        id: hlistview
        anchors.top: title.bottom
        anchors.bottom: parent.bottom
        width: parent.width
        radius: 5
        visible: index == 1 ? true : false
    }

    function showBPM(bpm) {
        heartrate.bpm = bpm
    }
    function showIBI(ibi) {
        heartrate.ibi = ibi
    }
    function showTemp(temp) {
        heartrate.temp = temp
    }

    function add_point(point) {
        heartrate.add_point(point)
    }

    function initHListView(content){
        hlistview.initList(content)
    }


    //onClose: startButton.onClieked()

}
